<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>表格换色</title>

    <style>
        table {
            margin: 100px auto;
            text-align: center;
        }
        
        table,
        tr,
        th {
            border: 1px solid black;
            scroll-padding: 0px;
        }
        
        table>thead {
            background-color: antiquewhite;
        }
        
        tr>th {
            padding: 0 50px 0 50px;
        }
    </style>

</head>


<body>
    <table cellspacing="0" cellpadding="0">
        <thead>
            <tr>
                <th>代码</th>
                <th>名称</th>
                <th>增长率</th>

            </tr>
        </thead>
        <tbody>
            <tr>
                <th>214124</th>
                <th>伟大伟大</th>
                <th>0.5</th>

            </tr>
            <tr>
                <th>214124</th>
                <th>哈皮</th>
                <th>0.5</th>

            </tr>
            <tr>
                <th>214124</th>
                <th>阿文大阿福</th>
                <th>0.5</th>

            </tr>
        </tbody>

    </table>

</body>

<script>
    var tr = document.getElementsByTagName('tr');


    for (var i = 1; i < tr.length; i++) {

        tr[i].onmouseover = function() {
            this.style.backgroundColor = 'red';
            this.style.cursor = 'pointer';
        }

        tr[i].onmouseleave = function() {
            this.style.backgroundColor = 'white';

        }
    }
</script>


</html>